//
//  WBNavigationController.swift
//  WeiBo
//
//  Created by lihaixing on 2018/11/29.
//  Copyright © 2018年 lihaixing. All rights reserved.
//

import UIKit

class WBNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        navigationBar.isHidden=true
        

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        if childViewControllers.count>0 {
           viewController.hidesBottomBarWhenPushed=true
            
            
            if let vc = viewController as? WBBaseViewController {
                var title="返回"
                if childViewControllers.count==1{
                    title = childViewControllers.first?.title ?? "返回"
                    
                }
                vc.naviItem.leftBarButtonItem=UIBarButtonItem.init(title: title, target:self, action: #selector(popBackToParentVC),isBack:true)
            }
            
        }
        
        super.pushViewController(viewController, animated: true)
    }
    
    @objc private func popBackToParentVC(){
        popViewController(animated: true)

    }

}
